length() returns the length of a string.
public static int strlen(String s) {
int length = s.length();
return length;
}
Function Call | Return Value | |||
---|---|---|---|---|
strlen("Car") | → | |||
strlen("") | → | |||
strlen("5") | → | |||
strlen("Elephant") | → | |||
strlen("Roses") | → |
Experiment with this code on Gitpod.io